package com.andy.beef.ui.main.adapter

import com.andy.beef.R
import com.andy.beef.ui.main.bean.MenuItemBean
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @creator:LuoFan
 * @date:2022/6/7
 * @description:
 */
class CategoryMenuAdapter : BaseMultiItemQuickAdapter<MenuItemBean, BaseViewHolder>(null) {

    init {
        addItemType(MenuItemBean.VIEW_TYPE_GROUP, R.layout.main_adapter_category_menu_group)
        addItemType(MenuItemBean.VIEW_TYPE_ITEM, R.layout.main_adapter_category_menu_item)
    }

    override fun convert(holder: BaseViewHolder, item: MenuItemBean) {
        when (holder.itemViewType) {
            MenuItemBean.VIEW_TYPE_GROUP -> {
                holder.setText(R.id.tv_name, item.name)
            }
            MenuItemBean.VIEW_TYPE_ITEM -> {
                holder.setText(R.id.tv_name, item.name)
                holder.setImageResource(R.id.img_center, item.img)
            }
        }
    }
}